<main class="lyear-layout-content">

    <div class="container-fluid p-t-15">
        <div class="row">
            <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                <div class="callout callout-success card card-body clearfix" style="flex-direction:row;">
                    <h4>{$navTitle == 'analysis' ? '用户数据统计' : ''}</h4>
                </div>
            </div>
        </div>

        <div class="row">

            <div class="col-md-6">
                <div class="card">
                    <div class="card-header">
                        <div class="card-title">性别</div>
                    </div>
                    <div class="card-body" style="text-align: center;">
                        <canvas id="chart-doughnut" width="280" height="280" style="display: inline;"></canvas>
                    </div>
                </div>
            </div>

            <div class="col-md-6">
                <div class="card">
                    <div class="card-header">
                        <div class="card-title">认证状态</div>
                    </div>
                    <div class="card-body" style="text-align: center;">
                        <canvas id="chart-pie" width="280" height="280" style="display: inline;"></canvas>
                    </div>
                </div>
            </div>

        </div>

    </div>
</main>

<script>

    $.ajax({
        type: "post",
        url: `{:url('admin/analysis/user')}`,
        data: {
            action: 'pie'
        },
        dataType: "json",
        success: function (res) {

            new Chart($('#chart-doughnut'), {
                type: 'doughnut',
                data: {
                    labels: ["男", "女", "保密"],
                    datasets: [{
                        data: res.data.sex,
                        backgroundColor: ['rgba(255,99,132,1)', 'rgba(54, 162, 235, 1)',
                            'rgba(255, 206, 86, 1)'
                        ]
                    }]
                },
                options: {
                    responsive: false,
                }
            })

            new Chart($('#chart-pie'), {
                type: 'pie',
                data: {
                    labels: ["已认证", "未认证"],
                    datasets: [{
                        label: '# of Votes',
                        data: res.data.auth,
                        backgroundColor: [
                        'rgba(54, 162, 235, 1)',
                            'rgba(255, 206, 86, 1)'
                        ],
                        borderWidth: 1
                    }]
                },
                options: {
                    responsive: false,
                }
            })
        }
    });
</script>